﻿namespace DeployPackA.Tests.LocalizationModels
{
    //.NET References
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Text;

    //LocalizationLibrary
    using LocalizationLibrary;
    using LocalizationLibrary.Attributes;
#if SILVERLIGHT
    using System.Windows;
#endif
    /// <summary>
    /// Simple presentation model.
    /// </summary>
    public class TestPropertyLocalizationModel : INotifyPropertyChanged
    {
        //Events

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        //Properties

        /// <summary>
        /// Test property.
        /// </summary>
        public String TestProperty { get; set; }
        
        //Methods

        /// Publishes the PropertyChanged event.
        /// </summary>
        /// <param name="propertyName">Property name.</param>
        [OnPropertyChangeMethod("propertyName")]
        protected internal void OnPropertyChange(String propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
#if SILVERLIGHT
                Action action = new Action(() =>
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                });
                Deployment.Current.Dispatcher.BeginInvoke(action);
#else
                handler(this, new PropertyChangedEventArgs(propertyName));
#endif
            }
        }
    }
}